package io.bluerain.ldrawersample.entities;

import android.app.Activity;
import android.content.Context;

import io.bluerain.ldrawersample.ItemFragment;
import io.bluerain.ldrawersample.ui.items.Test01;

/**
 * Created by foredawn on 15-9-23.
 * listView的menu继承基类
 */
public class Menu {

    public interface ClickListener {
        void onClick(Context context);
    }

    public static String[] KEYS = new String[]{"img", "text"};
    public static String KER_IMG = KEYS[0];
    public static String KEY_TEXT = KEYS[1];


    private ClickListener clickListener;
    private int imgId;
    private String text;
    private ItemFragment frag;

    public Menu(int imgId, String text) {
        this.imgId = imgId;
        this.text = text;
    }

    public Menu(int imgId, String text, Class<?> fragmentClass, int resource) {
        this.imgId = imgId;
        this.text = text;
        if (fragmentClass != null) {
            try {
                this.frag = (ItemFragment) fragmentClass.newInstance();
                this.frag.setMenuItem(this);
                this.frag.setResource(resource);
            } catch (InstantiationException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }
    }

    public Menu(int imgId, String text, ClickListener clickListener) {
        this.imgId = imgId;
        this.text = text;
        this.clickListener = clickListener;
    }

    public int getImgId() {
        return imgId;
    }

    public void setImgId(int imgId) {
        this.imgId = imgId;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public ItemFragment getFrag() {
        return frag;
    }

    public void setFrag(ItemFragment frag) {
        this.frag = frag;
    }

    public ClickListener getClickListener() {
        return clickListener;
    }

    public void setClickListener(ClickListener clickListener) {
        this.clickListener = clickListener;
    }
}
